package com.jindy.module.receiptorder.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.jindy.common.utils.poi.ExcelUtil;
import com.jindy.module.receiptorder.domain.ReceiptOrderProduct;
import com.jindy.module.receiptorder.service.IReceiptOrderProductService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jindy.common.annotation.Log;
import com.jindy.common.core.controller.BaseController;
import com.jindy.common.core.domain.AjaxResult;
import com.jindy.common.enums.BusinessType;
import com.jindy.common.core.page.TableDataInfo;

/**
 * 【入库单产品】Controller
 *
 * @author ruoyi
 * @date 2022-10-12
 */
@RestController
@RequestMapping("/module/receiptOrderProduct")
public class ReceiptOrderProductController extends BaseController
{
    @Autowired
    private IReceiptOrderProductService receiptOrderProductService;

    /**
     * 查询【入库单产品】列表
     */
//    @PreAuthorize("@ss.hasPermi('module:receiptOrderProduct:list')")
    @GetMapping("/list")
    public TableDataInfo list(ReceiptOrderProduct receiptOrderProduct)
    {
        startPage();
        List<ReceiptOrderProduct> list = receiptOrderProductService.selectReceiptOrderProductList(receiptOrderProduct);
        return getDataTable(list);
    }

    /**
     * 导出【入库单产品】列表
     */
//    @PreAuthorize("@ss.hasPermi('module:receiptOrderProduct:export')")
    @Log(title = "【入库单产品】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ReceiptOrderProduct receiptOrderProduct)
    {
        List<ReceiptOrderProduct> list = receiptOrderProductService.selectReceiptOrderProductList(receiptOrderProduct);
        ExcelUtil<ReceiptOrderProduct> util = new ExcelUtil<ReceiptOrderProduct>(ReceiptOrderProduct.class);
        util.exportExcel(response, list, "【入库单产品】数据");
    }

    /**
     * 获取【入库单产品】详细信息
     */
//    @PreAuthorize("@ss.hasPermi('module:receiptOrderProduct:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(receiptOrderProductService.selectReceiptOrderProductById(id));
    }

    /**
     * 新增【入库单产品】
     */
//    @PreAuthorize("@ss.hasPermi('module:receiptOrderProduct:add')")
    @Log(title = "【入库单产品】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ReceiptOrderProduct receiptOrderProduct)
    {
        return toAjax(receiptOrderProductService.insertReceiptOrderProduct(receiptOrderProduct));
    }

    /**
     * 修改【入库单产品】
     */
//    @PreAuthorize("@ss.hasPermi('module:receiptOrderProduct:edit')")
    @Log(title = "【入库单产品】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ReceiptOrderProduct receiptOrderProduct)
    {
        return toAjax(receiptOrderProductService.updateReceiptOrderProduct(receiptOrderProduct));
    }

    /**
     * 删除【入库单产品】
     */
//    @PreAuthorize("@ss.hasPermi('module:receiptOrderProduct:remove')")
    @Log(title = "【入库单产品】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(receiptOrderProductService.deleteReceiptOrderProductByIds(ids));
    }
}
